package com.hungryinlindholmen;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Receives a request from ownerresult.jsp and creates a DeleteDb object
 * depending on parameters received. The parameter delDone is set to null.
 * Forwards to owner.jsp with parameters delDone and restID.
 * 
 * @author Ludvig Gee
 */

@WebServlet("/DeleteServlet")
public class DeleteServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest request,
	    HttpServletResponse response) throws ServletException, IOException {
	String dish = request.getParameter("dish");
	String option = request.getParameter("option");
	String restID = (String) request.getSession().getAttribute("restID");
	request.setAttribute("delDone", null);

	DeleteDb del = new DeleteDb(restID);
	del.DeleteAction(restID, dish, option);

	request.setAttribute("restID", del.getRestID());
	request.setAttribute("delDone", del.getDeleteDone());
	RequestDispatcher dispatcher = request
		.getRequestDispatcher("owner.jsp");
	dispatcher.forward(request, response);
	return;
    }

}
